package 预习第九天.Map;

import com.sun.jdi.Value;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        // 创建一个Map对象，键为String类型，值为Integer类型
        Map<String,Integer> map= new HashMap<>();
        // 向Map中添加键值对
        map.put("手表",100);
        map.put("电脑",200);
        map.put("手机",300);
        map.put("电视",400);
        map.put("冰箱",500);
        map.put("洗衣机",null);

/*        Set <String> keySet = map.keySet();
        System.out.println(keySet);
         Collection<Integer> values= map.values();
         System.out.println(values);*/

         Map<String,Integer> map1 = new HashMap<>();
         map1.put("电脑1",200);
         map1.put("手机",900);
         map1.put("电视1",400);
         Map<String,Integer> map2 = new HashMap<>();
         map2.put("电脑1",200);
         map2.put("手机2",300);
         map2.put("电视2",400);
         map.putAll(map1);
         map1.putAll(map2);
         System.out.println(map);

        // 输出Map对象
        System.out.println(map);
        // 输出Map对象的大小
        System.out.println(map.size());
/*        System.out.println(map.isEmpty());
        map.clear();
        System.out.println(map);
        System.out.println(map.isEmpty());*/
        Integer 电脑 = map.get("电脑");
        System.out.println(电脑); // 输出Map对象中键为"电脑"的值
        System.out.println(map.get("电脑")); // 输出Map对象中键为"电脑"的值
        System.out.println(map.get("手表"));// 输出Map对象中键为"手表"的值

        System.out.println(map.remove("电脑"));
        System.out.println(map);

        System.out.println(map.containsKey("电脑"));
        System.out.println(map.containsKey("手表"));
        System.out.println(map.containsValue(100));
        System.out.println(map.containsValue(200));


    }
}
